//  假如我只想引入module_a中的mutationType，那么我可以单独建立一个moduleA的js文件
import MutationType from '../../mutation_type'
const state = {
  count: 0,
  sum: 0,
  showSearch: false
}
// debugger
const mutations = {
  [MutationType.CALCULATE] (state) {
    // console.log(state.count)
    state.count += 1
  },
  [MutationType.SUM] (state) {
    state.sum += state.count
  },
  [MutationType.ORDER_SEARCH] (state, searchState) {
    // console.log(searchState.judge)
    state.showSearch = searchState.judge
  }
}

const actions = {
  calculate ({ commit }) {
    commit(MutationType.CALCULATE)
    commit(MutationType.SUM)
  },
  showSearch ({ commit }) {
    commit({
      type: MutationType.ORDER_SEARCH,
      judge: !state.showSearch
    })
  }
}

export default {
  state,
  mutations,
  actions
}
